package ModelLayer;

import java.util.ArrayList;

public class Forest {
	private String name;
	private String location;
	private float squareMeter;
	private String natureOfTrees;
	private float price;
	
	//Container for alot of trees
	private ArrayList<Tree> treeContainer;
	
	//Constructor without parameters
	public Forest(){
	}
	/**
	 * Constructor
	 * @param String name, String location, float squareMeter, String NatureOfTrees, float Price
	 * */
	public Forest(String name, String location, float squareMeter, String nOT, float price){
		this.name = name;
		this.location = location;
		this.squareMeter = squareMeter;
		this.natureOfTrees = nOT;
		this.price = price;
		
		treeContainer = new ArrayList<Tree>();
	}
	//Get and set name
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	//Get and set location
	public String getLocation() {
		return location;
	}
	public void setLocation(String location) {
		this.location = location;
	}
	//Get and set squaremeter
	public float getSquareMeter() {
		return squareMeter;
	}
	public void setSquareMeter(float squareMeter) {
		this.squareMeter = squareMeter;
	}
	//Get and set Natureoftrees
	public String getNatureOfTrees() {
		return natureOfTrees;
	}
	public void setNatureOfTrees(String natureOfTrees) {
		this.natureOfTrees = natureOfTrees;
	}
	//Get and set price
	public float getPrice() {
		return price;
	}
	public void setPrice(float price) {
		this.price = price;
	}
	
	/**
	 * Add tree to treecontainer
	 * @param Tree tree
	 * */
	public void addTree(Tree tree){
		treeContainer.add(tree);
	}
	/**
	 * Find tree by sort and return it.
	 * @param String sort
	 * @return Tree
	 * */
	public Tree getTree(String sort){
		boolean search = false;
		int i = 0;
		Tree t = null;
		while(!search && i < treeContainer.size()){
			t = treeContainer.get(i);
			if(t.getSort() == sort){
				search = true;
			}else{
				i++;
			}
		}
		if(search){
			return treeContainer.get(i);
		}else{
			return null;
		}
	}
	/**
	 * Remove tree
	 * @param String sort
	 * */
	public void removeTree(String sort){
		Tree t = getTree(sort);
		treeContainer.remove(t);
	}
	
	/**
	 * Get all trees
	 * @return All trees
	 * */
	public ArrayList<Tree> getAllTrees(){
		return treeContainer;
	}
}
